package com.police.base;

import org.xutils.x;

import com.police.view.kprogresshud.KProgressHUD;

import android.app.Activity;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.graphics.Color;
import android.os.Bundle;

/** 
* @ClassName: BaseActivity 
* @Description: activity的基类 
* @author liming
* @date 2016年6月23日 上午11:07:52 
*  
*/ 
public class BaseActivity extends Activity
{
	protected KProgressHUD hud;
	 
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
       
        // xUtils视图注入
        x.view().inject(this);
      
        // 创建默认的动作条
        hud = KProgressHUD.create(this)
                  .setCancellable(true)
                  .setWindowColor(Color.argb(200, 165, 192, 247))
        		  .setStyle(KProgressHUD.Style.SPIN_INDETERMINATE)
        		  .setOnCancelListener(new OnCancelListener()
        		  {
					@Override
					public void onCancel(DialogInterface arg0) 
					{
						canceledHud();
					}
				});
        		  
    }
    
    
    /**   
     * @Title: showHud   
     * @Description: 显示默认进度条 
     * @param:       
     * @return: void      
     * @throws   
     */ 
    protected void showHud()
	{
    	if(hud != null)
    	{ 
    		hud.show();
    	}
	}
    
    
    /**   
     * @Title: dismissHud   
     * @Description: 关闭进度条 
     * @param:       
     * @return: void      
     * @throws   
     */ 
    protected void dismissHud()
	{
		if(hud != null)
    	{ 
			hud.dismiss();
    	}
	}
    
    /**   
     * @Title: canceledHud   
     * @Description: 取消进度条时，需要进行一些服务，重载该方法 
     * @param:       
     * @return: void      
     * @throws   
     */ 
    protected void canceledHud()
    {
    	
    }
}
